{extend name="base" /}
{block name="title"}保险录入{/block}
{block name="static"}
<link rel="stylesheet" type="text/css" media="screen" href="/static/pc/css/select.css"/>
{/block}
{block name="bread"}
<div class="bread-cram">
    <div class="bread-cram-inner">
        <span class="title">保险公司使用</span>
        <span class='sub-title'>- 保险录入</span>
    </div>
</div>
{/block}

{block name="main"}

<div class="menu-content left">
    <div class="menu-content-title">
        <p>资料录入</p>
    </div>
    <div class="step-box">
        <div class="active">保单险种</div>
        <div>货品信息</div>
        <div>货品受损</div>
        <div>货品现状</div>
        <div>物权信息</div>
        <div>递交授权</div>
    </div>
    <div class="msg-tip" style="text-align: center">
        *以下资料作为法律责任依据请如实填写,<a>查看模板>></a>
    </div>
    <div class="form-box">
        <div class="form-content">
            <div class="form-item">
                <label>保单号：</label>
                <input type="text" placeholder="请填写保单号" name="report_num" onkeyup="value=value.replace(/[\u4e00-\u9fa5]/ig,'')"/>
            </div>
            <div class="form-item">
                <label>报案号：</label>
                <input type="text" placeholder="请填写报案号" name="policy_num" onkeyup="value=value.replace(/[\u4e00-\u9fa5]/ig,'')"/>
            </div>
            <div class="form-item">
                <label>出险险种：</label>
                <select class="demo" multiple="multiple" placeholder="请选择险种"   >
                    {volist name="list" id="vo"}
                    <option value="{$vo.it_id}">{$vo.it_name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="form-footer">
            <div class="step-btn-box">
                <div class="save-btn">下一步</div>

            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script type="text/javascript">
    $(function() {
        $('.demo').fSelect({
            placeholder: '请选择出险险种',
            numDisplayed: 3,
            overflowText: '{n} selected',
            searchText: 'Search',
            showSearch: true
        });
        $('.save-btn').on('click', function () {
            var poliecy = $("input[ name='policy_num']").val();
            var report_num = $("input[ name='report_num']").val();
            var insurance_type = $(".demo").val();
            if (report_num.length == 0) {
                layer.msg('请填写保单号', {icon: 2});
                return;
            }
            if (poliecy.length == 0) {
                layer.msg('请填写报案号', {icon: 2});
                return;
            }
            if (insurance_type.length ==0) {
                layer.msg('请选择出险险种', {icon: 2});
                return;
            }
            var str = '';
            for (i=0;i< insurance_type.length;i++){
                str+=insurance_type[i]+',';
            }
            $.ajax({
                type: 'POST',
                url: "{:url('insurer/addInsurer')}",
                data: {
                    'policy_num': poliecy,
                    'report_num': report_num,
                    'insurance_type': str.substring(0,str.length-1),
                    'now_status':1
                },
                dataType: 'json',
                success: function (Json) {
                    if (Json.code == 200) {
                        location.href="{:url('insurer/step2')}?policy_num="+Json.data.policy_num;
                    } else {
                        $.alert(Json.msg);
                    }
                }
            });
        });
    })

</script>
{/block}